import React, { Component } from 'react'
import { Provider } from './FormContext'
import Input from '../Input'
import Button from '../Button'
console.log(Provider)
export default class Form extends Component {
  constructor(props){
    super(props)
  }
  state = {
    ctx:{
      formData:{},
      changeFormData:(name,val)=>{
        let ctx = {
            ...this.state.ctx,
            formData:{
              ...this.state.ctx.formData,
            [name]:val
            }
          // }
        }
        this.setState({
          ctx:ctx
        })
    },
    sumbitVal:()=>{
      console.log(this.state.ctx.formData)
    }
    }
    
  }
  shouldComponentUpdate(nextProps){
    console.log('更新')
    return true
  }
  render() {
    console.log('父组件')
    return (
      <Provider value={
        this.state.ctx
      }>
        {/* <Form.Input /> */}
        {/* {this.props.children} */}
        {this.props.children}
      </Provider>
    )
  }
}
Form.input = Input
Form.button = Button